<script type="text/javascript">
<!--
{literal}
    $(document).ready(function(){
        $('table#bedTbl tr:even').addClass('alt');
    });
{/literal}    
//-->
</script>
<table id="bedTbl" class="grid" width="800px;" cellpadding="0" cellspacing="0">
    <thead>
        <tr>
            <th class="first" width="25">{translate}No.{/translate}</th>
            <th>{translate}Department{/translate}</th>
            <th width="70">{translate}Bed code{/translate}</th>
            <th width="60">{translate}Start date{/translate}</th>
            <th width="60">{translate}End date{/translate}</th>
            <th width="40">{translate}Day number{/translate}</th>
            <th width="50">{translate}Unit price{/translate}</th>
            <th width="50">{translate}Price{/translate}</th>
            <th width="50">{translate}Insurance payment{/translate}</th>
            <th class="last" width="60">{translate}Patient payment_1{/translate}</th>
        </tr>
    </thead>
    <tbody>
    {if !empty($bedList)}
    {php} $total    =   array('originalPrice' => 0,'patientPrice' => 0, 'insurancePrice' => 0);{/php}
    {foreach from=$bedList item=bed}
        <tr>
            <td class="first">{$index++}</td>
            <td>{$bed.department_name}</td>
            <td>{$bed.bed_code}</td>
            <td>{$bed.start_date}</td>
            <td>{$bed.end_date}</td>
            <td>{$bed.day_number}</td>
            {php}
                $bed = $this->get_template_vars('bed');
                $total['originalPrice'] += $bed['original_price'];
                $total['insurancePrice'] += $bed['insurance_price'];
                $total['patientPrice'] += $bed['patient_price'];
                $col    =   '';
                $col    .=  '<td>' . L10nHelper::renderCurrency($bed['unit_price']) .'</td>';
                $col    .=  '<td>' . L10nHelper::renderCurrency($bed['original_price']) .'</td>';
                $col    .=  '<td>' . L10nHelper::renderCurrency($bed['insurance_price']) .'</td>';
                $col    .=  '<td class="last">' . L10nHelper::renderCurrency($bed['patient_price']) .'</td>';
                echo $col;
            {/php}
        </tr>
    {/foreach}
    {php}
        $totalRow   =   '';
        $totalRow    .=  '<tr>
            <td class="fisrt" colspan="7" align="right"><span style="color: red; font-weight: bold">'. L10nHelper::_("Total"). '</span></td>
            <td><span style="color: red; font-weight: bold">' . L10nHelper::renderCurrency($total["originalPrice"]) . '</span></td>
            <td><span style="color: red; font-weight: bold">' . L10nHelper::renderCurrency($total["insurancePrice"]) . '</span></td>
            <td class="last"><span style="color: red; font-weight: bold">'. L10nHelper::renderCurrency($total["patientPrice"]) . '</span></td>
            </tr>';
        echo $totalRow;
    {/php}
    {else}
        <tr><td colspan="10" class="first last">{translate}There is no information on beds the patient has used{/translate}</td>
    {/if}
    </tbody>
</table>